export const BpmMixin = {
  props: {
    bpmId: {
      type: String,
      default: null
    },
    bpmIdType: {
      type: String,
      default: null
    },
    processInstanceId: {
      type: String,
      default: null
    },
    processDefId: {
      type: String,
      default: null
    },
    getBpmOperateVoUrl: {
      type: String,
      default: null
    },
    formId: {
      type: String,
      default: null
    },
    formCode: {
      type: String,
      default: null
    },
    layoutCode: {
      type: String,
      default: null
    },
    buttonDatas: {
      type: Object,
      default: () => {
      }
    },
    showCloseBut: {
      type: Boolean,
      default: false
    },
    processInstanceName: {
      type: String,
      default: ''
    },
  },
  data () {
    return {
      editableList: [],
      requiredList: [],
      hiddenList: [],
      startPage: false,
      refreshProcess: 0,
    }
  },
  methods: {
    refreshParent () {
      this.$emit('refreshParent')
    },
    changeTask (task) {
      this.$emit('changeTask', task)
    },
    close () {
      this.$emit('close')
    },
    setEditableList (editableList, startPage, requiredList, hiddenList) {
      this.startPage = startPage
      this.editableList = editableList
      this.requiredList = requiredList || []
      this.hiddenList = hiddenList || []
    },
    setCurProcessData (buttonDatas) {
      this.$emit('setCurProcessData', buttonDatas)
      this.refreshProcess = this.refreshProcess + 1
    }
  },
  mounted () {
    if (!this.formId && this.bpmIdType == 'formCode' || this.bpmIdType == 'processDefId') {
      this.add()
    } else {
      this.detail()
    }
  }
}
